# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.ServiceControl.V2.Model.Request do
  @moduledoc """
  This message defines attributes for an HTTP request. If the actual request is not an HTTP request, the runtime system should try to map the actual request to an equivalent HTTP request.

  ## Attributes

  *   `auth` (*type:* `GoogleApi.ServiceControl.V2.Model.Auth.t`, *default:* `nil`) - The request authentication. May be absent for unauthenticated requests. Derived from the HTTP request `Authorization` header or equivalent.
  *   `headers` (*type:* `map()`, *default:* `nil`) - The HTTP request headers. If multiple headers share the same key, they must be merged according to the HTTP spec. All header keys must be lowercased, because HTTP header keys are case-insensitive.
  *   `host` (*type:* `String.t`, *default:* `nil`) - The HTTP request `Host` header value.
  *   `id` (*type:* `String.t`, *default:* `nil`) - The unique ID for a request, which can be propagated to downstream systems. The ID should have low probability of collision within a single day for a specific service.
  *   `method` (*type:* `String.t`, *default:* `nil`) - The HTTP request method, such as `GET`, `POST`.
  *   `origin` (*type:* `String.t`, *default:* `nil`) - The values from Origin header from the HTTP request, such as "https://console.cloud.google.com". Modern browsers can only have one origin. Special browsers and/or HTTP clients may require multiple origins.
  *   `path` (*type:* `String.t`, *default:* `nil`) - The HTTP URL path, excluding the query parameters.
  *   `protocol` (*type:* `String.t`, *default:* `nil`) - The network protocol used with the request, such as "http/1.1", "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids for details.
  *   `query` (*type:* `String.t`, *default:* `nil`) - The HTTP URL query in the format of `name1=value1&name2=value2`, as it appears in the first line of the HTTP request. No decoding is performed.
  *   `reason` (*type:* `String.t`, *default:* `nil`) - A special parameter for request reason. It is used by security systems to associate auditing information with a request.
  *   `scheme` (*type:* `String.t`, *default:* `nil`) - The HTTP URL scheme, such as `http` and `https`.
  *   `size` (*type:* `String.t`, *default:* `nil`) - The HTTP request size in bytes. If unknown, it must be -1.
  *   `time` (*type:* `DateTime.t`, *default:* `nil`) - The timestamp when the `destination` service receives the last byte of the request.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :auth => GoogleApi.ServiceControl.V2.Model.Auth.t() | nil,
          :headers => map() | nil,
          :host => String.t() | nil,
          :id => String.t() | nil,
          :method => String.t() | nil,
          :origin => String.t() | nil,
          :path => String.t() | nil,
          :protocol => String.t() | nil,
          :query => String.t() | nil,
          :reason => String.t() | nil,
          :scheme => String.t() | nil,
          :size => String.t() | nil,
          :time => DateTime.t() | nil
        }

  field(:auth, as: GoogleApi.ServiceControl.V2.Model.Auth)
  field(:headers, type: :map)
  field(:host)
  field(:id)
  field(:method)
  field(:origin)
  field(:path)
  field(:protocol)
  field(:query)
  field(:reason)
  field(:scheme)
  field(:size)
  field(:time, as: DateTime)
end

defimpl Poison.Decoder, for: GoogleApi.ServiceControl.V2.Model.Request do
  def decode(value, options) do
    GoogleApi.ServiceControl.V2.Model.Request.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.ServiceControl.V2.Model.Request do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
